class Counter:
    def __init__(self,low,high):
        self.current=low
        self.high=high

    def __iter__(self):
        return self

    def __next__(self):
        if self.current > self.high:
            raise StopIteration
        else:
            self.current+=1
            return self.current-1

c=Counter(5,10)
for i in c:
    print(i,end=' ')
print('\n')

iterator=iter(Counter(5,10))
while True:
    try:
        x=iterator.__next__()
        print(x,end=' ')
    except StopIteration:
        break
